package com.netscenery.yang.model;

import com.netscenery.util.ErrTag;

public class ModelException extends Exception {
	private ErrTag errorTag;
	private String description;
	public ModelException(ErrTag errorTag,String description){
		this.errorTag = errorTag;

		this.setDescription(description);
	}

	/**
	 * @return the errorTag
	 */
	public ErrTag getErrorTag() {
		return errorTag;
	}

	/**
	 * @param errorTag the errorTag to set
	 */
	public void setErrorTag(ErrTag errorTag) {
		this.errorTag = errorTag;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		switch(this.errorTag){
		case ERROR:{
			sb.append("Error:");
			break;
		}
		case WARNING:{
			sb.append("Warning:");
			break;
		}
		case INFO:{
			sb.append("Info:");
			break;
		}
		case DEBUG:{
			sb.append("Debug:");
			break;
		}
		default:{
			return null;
		}
		}
		
		
		sb.append(this.description);
		sb.append("\n");
		
		return sb.toString();
		
	}
}
